<?php

namespace app\system\service;

use app\model\SystemDictData;
use think\helper\Arr;

class DataDictService
{
    public function getList(?array $params = null, bool $isScope = false): array
    {
        $query = SystemDictData::where(['status' => 1]);
        if ($code = Arr::get($params, 'code')) {
            $query->where(['code' => $code]);
        }
        return $query->field(['id', 'label as title', 'value as `key`'])
            ->order('sort', 'desc')
            ->select()->toArray();
    }
}